#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	freopen("candy.in", "r", stdin);
	freopen("candy.out", "w", stdout);
	int n, L, R, k, ans = -1;
	scanf("%d%d%d", &n, &L, &R);
	if(L + n - (L % n) <= R) printf("%d", n - 1);
	else printf("%d", R % n);
	fclose(stdin), fclose(stdout);
	return 0;
}
